﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Tasks;
using System.Windows.Media.Imaging;

namespace SMARTMobile.Views
{
    public partial class HoTroPage
    {
        PhotoChooserTask selectphoto = null;

        public HoTroPage()
        {
            InitializeComponent();
        }

        private void ImageError_Tap(object sender, System.Windows.Input.GestureEventArgs e) 
        {
            this.selectphoto = new PhotoChooserTask();
            this.selectphoto.Completed += selectphoto_Completed;
            this.selectphoto.Show();
        }

        private void selectphoto_Completed(object sender, PhotoResult e)
        {
            if (e.TaskResult == TaskResult.OK)
            {
                BitmapImage image = new BitmapImage();
                image.SetSource(e.ChosenPhoto);
                this.ImageError.Source = image;
            }
        }

        private void ExitButton_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri("/Views/MainPage.xaml", UriKind.Relative));
        }
    }
}